package com.example.jwt_moudle.config;

import com.example.jwt_moudle.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description web配置
 * @Author lihw
 * @Date 2023/12/28 10:56
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry
                .addInterceptor(new LoginInterceptor())
                .addPathPatterns("/test/pri/**") //需要拦截的路径
                .excludePathPatterns("/test/pub/**"); // 不需要拦截的路径

        /**
         * 多拦截器示例 如下
         */
        // 添加拦截器1，并设置拦截路径为 "/path1"
        // registry.addInterceptor(new CustomInterceptor1()).addPathPatterns("/path1/**");
        // 添加拦截器2，并设置拦截路径为 "/path2"
        // registry.addInterceptor(new CustomInterceptor2()).addPathPatterns("/path2/**");
    }
}
